package cn.jy.authority.controller;

import cn.jy.authority.service.IExpressageColumnService;
import cn.jy.common.authority.ExpressageColumn;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/column")
public class ExpressageColumnController extends BaseController
{
    @Autowired
    private IExpressageColumnService expressageColumnService;

    /**
     * 查询快递管理菜单列表
     */
//    @RequiresPermissions("system:column:list")
    @GetMapping("/list")
    public TableDataInfo list(ExpressageColumn expressageColumn)
    {
        List<ExpressageColumn> list = expressageColumnService.selectExpressageColumnList(expressageColumn);
        return getDataTable(list);
    }

    /**
     * 导出快递管理菜单列表
     */
//    @RequiresPermissions("system:column:export")
    @Log(title = "快递管理菜单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpressageColumn expressageColumn)
    {
        List<ExpressageColumn> list = expressageColumnService.selectExpressageColumnList(expressageColumn);
        ExcelUtil<ExpressageColumn> util = new ExcelUtil<ExpressageColumn>(ExpressageColumn.class);
        util.exportExcel(response, list, "快递管理菜单数据");
    }

    /**
     * 获取快递管理菜单详细信息
     */
//    @RequiresPermissions("system:column:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(expressageColumnService.selectExpressageColumnById(id));
    }

    /**
     * 新增快递管理菜单
     */
//    @RequiresPermissions("system:column:add")
    @Log(title = "快递管理菜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpressageColumn expressageColumn)
    {
        return toAjax(expressageColumnService.insertExpressageColumn(expressageColumn));
    }

    /**
     * 修改快递管理菜单
     */
//    @RequiresPermissions("system:column:edit")
    @Log(title = "快递管理菜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpressageColumn expressageColumn)
    {
        return toAjax(expressageColumnService.updateExpressageColumn(expressageColumn));
    }

    /**
     * 删除快递管理菜单
     */
//    @RequiresPermissions("system:column:remove")
    @Log(title = "快递管理菜单", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(expressageColumnService.deleteExpressageColumnByIds(ids));
    }
}